package com.helen.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.coorchice.library.SuperTextView;
import com.helen.entity.AddressListEntity;
import com.helen.entity.MyRecoveryEntity;
import com.helen.shopping.R;
import com.helen.utils.MyLog;

import java.util.List;


/**
 * Created by yang on 2018/5/2.
 */

public class MyRecoveryListAdapter extends BaseQuickAdapter<MyRecoveryEntity, BaseViewHolder> {
    private OnSetItemBuyListener onItemBuyListener;

    public MyRecoveryListAdapter(List<MyRecoveryEntity> data) {
        super(R.layout.item_my_recovery, data);

    }


    @Override
    protected void convert(final BaseViewHolder helper, final MyRecoveryEntity item) {
        try {
            TextView tvTitle = (TextView) helper.getView(R.id.tv_title);
            TextView tvCount1 = (TextView) helper.getView(R.id.tv_count1);
            TextView tvCount2 = (TextView) helper.getView(R.id.tv_count2);
            TextView tv_shouyi = (TextView) helper.getView(R.id.tv_shouyi);
            TextView tv_shouming = (TextView) helper.getView(R.id.tv_shouming);
            TextView tvMoney = (TextView) helper.getView(R.id.tv_money);
            SuperTextView tvBuy = (SuperTextView) helper.getView(R.id.tv_buy);
            tvTitle.setText(item.getName());
            tvCount1.setText(item.getCount() + "");
            tvCount2.setText(item.getBuyCount() + "");
            tvMoney.setText(item.getMoney() + "");
            tv_shouyi.setText(item.getDayMoney());
            tv_shouming.setText(item.getDays());
            tvBuy.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (onItemBuyListener != null) {
                        onItemBuyListener.setOnBuyListener(item, helper.getAdapterPosition());
                    }

                }
            });

        } catch (Exception e) {
            MyLog.e("yang", "设置我的回收车列表异常" + e.toString());
        }


    }

    public interface OnSetItemBuyListener {
        void setOnBuyListener(MyRecoveryEntity myRecoveryEntity, int position);
    }


    public void setOnItemBuyListener(OnSetItemBuyListener onItemBuyListener) {

        this.onItemBuyListener = onItemBuyListener;
    }
}
